package com.example.myapplication

import android.os.Bundle
import androidx.activity.ComponentActivity
import androidx.activity.compose.setContent
import androidx.activity.enableEdgeToEdge
import androidx.compose.foundation.Image
import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.Spacer
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.height
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.size
import androidx.compose.foundation.layout.width
import androidx.compose.material3.Scaffold
import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.draw.alpha
import androidx.compose.ui.draw.blur
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.layout.ContentScale
import androidx.compose.ui.res.painterResource
import androidx.compose.ui.text.font.Font
import androidx.compose.ui.text.font.FontStyle
import androidx.compose.ui.text.style.TextAlign
import androidx.compose.ui.tooling.preview.Preview
import androidx.compose.ui.unit.dp
import androidx.compose.ui.unit.sp
import com.example.myapplication.ui.theme.MyApplicationTheme

class MainActivity : ComponentActivity() {
    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        enableEdgeToEdge()
        setContent {
            MyApplicationTheme {
                Scaffold(modifier = Modifier.fillMaxSize()) { innerPadding ->
                  Greeting(
                        name = "Yinting",
                        modifier = Modifier.padding(innerPadding)
                    )
                }
            }
        }
    }
}

@Composable
fun Greeting(name: String, modifier: Modifier = Modifier) {
    val img= painterResource(R.drawable.oip_c)
    val img1= painterResource(R.drawable.__1_)
    val img2= painterResource(R.drawable.oip_c__3_)
    val img3= painterResource(R.drawable.oip_c__10_)

// 可以添加一些修饰使背景图更美观
    Image(
        painter = painterResource(id = R.drawable.oip_c__7_),
        contentDescription = "背景图片", // 更好的可访问性
        contentScale = ContentScale.Crop,
        modifier = Modifier
            .fillMaxSize()
            .alpha(4f) // 可选：添加透明度让内容更易读
            .blur(radius = 1.dp) // 可选：轻微模糊效果
    )
    Column(
        verticalArrangement = Arrangement.Center,
        horizontalAlignment = Alignment.CenterHorizontally,
        modifier = modifier.fillMaxSize()
    ){
        Spacer(modifier= Modifier.height(100.dp))
        Column(
            verticalArrangement = Arrangement.Center,
            horizontalAlignment = Alignment.CenterHorizontally,
            modifier = modifier.fillMaxSize().weight(1f,false)
        ){
            Image(
                painter = img,
                contentDescription = null,
                alpha = 0.6F,
                modifier = Modifier.padding(vertical = 10.dp).size(160.dp)
            )
            Text(
                text = "Hello $name!",
                textAlign = TextAlign.Center,
                fontSize = 50.sp,
                lineHeight = 50.sp,
                modifier= Modifier.padding(vertical = 10.dp)
            )
            Text(
                text = "Dou Po Cang Qiong",
                fontSize = 30.sp,
                lineHeight = 30.sp,
                color = Color.Red,
                fontStyle = FontStyle.Italic,
                modifier=Modifier.padding(vertical = 10.dp)
            )
        }
        Spacer(modifier= Modifier.height(100.dp))
        Column(verticalArrangement = Arrangement.Center,
            horizontalAlignment = Alignment.CenterHorizontally,
            modifier = modifier.fillMaxWidth().weight(1f,false)
        ){
            Row (horizontalArrangement = Arrangement.Center,
                verticalAlignment = Alignment.CenterVertically,
                modifier = Modifier.padding(vertical = 5.dp)){
                Image(
                    painter = img2,
                    contentDescription = null,
                    modifier = Modifier.height(30.dp).width(30.dp)
                )
                Text(
                    text="18785796300",
                    textAlign = TextAlign.Center,
                    fontSize = 20.sp,
                    lineHeight = 20.sp,
                    modifier= Modifier
                )
            }
            // 可以添加一些修饰使背景图更美观

            Row(
                horizontalArrangement = Arrangement.Center,
                verticalAlignment = Alignment.CenterVertically,
                modifier = Modifier.padding(vertical = 5.dp)
            ){
                Image(
                    painter = img1,
                    contentDescription = null,
                    modifier = Modifier
                        .height(30.dp)
                        .width(30.dp)
                )
                Text(
                    text = "29830077060",
                    textAlign = TextAlign.Center,
                    fontSize = 20.sp,
                    lineHeight = 20.sp,
                    modifier = Modifier
                )
            }
            Row(
                horizontalArrangement = Arrangement.Center,
                verticalAlignment = Alignment.CenterVertically,
                modifier = Modifier.padding(vertical = 5.dp)
            ){
                Image(
                    painter = img3,
                    contentDescription = null,
                    modifier = Modifier
                        .height(30.dp)
                        .width(30.dp)
                )
                Text(
                    text = "AndroidYinting",
                    textAlign = TextAlign.Center,
                    color = Color(0xFF4B9FD9),
                    fontSize = 20.sp,
                    lineHeight = 20.sp,
                    modifier = Modifier
                )
            }
        }
    }
}

@Preview(showBackground = true)
@Composable
fun GreetingPreview() {
    MyApplicationTheme {
        Greeting("Yinting")
    }
}